/**
 * Copyright [2019] [LiBo/Alex of copyright liboware@gmail.com ]
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.infodb.file.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * @project-name:infodb
 * @package-name:com.hyts.infodb.file.config
 * @author:LiBo/Alex
 * @create-date:2020-01-16 17:45
 * @copyright:libo-alex4java
 * @email:liboware@gmail.com
 * @description: 上传文件服务的配置操作
 */

@Configuration
@Data
@ConfigurationProperties(prefix ="upload")
public class UploadFileConfiguration {

    /**
     * 获取存放位置
     */
    private Map<String, String> localtion;

    /**
     * 单个文件大小
     */
    private Integer maxFileSize;

    /**
     * 单次上传总文件大小
     */
    private Integer maxRequestSize;

    /**
     * 获取基础路径操作
     * @return
     */
    public String getBasePath() {
        String location = "";
        String os = System.getProperty("os.name");
        if(os.toLowerCase().startsWith("win")) {
            location = this.getLocaltion().get("windows");
        } else {
            location = this.getLocaltion().get("linux");
        }
        return location;
    }

}
